//
//   TermsnprivacyView.swift
//  IncomeAndExpense
//
//  Created by HOA on 2021/8/21.
//

import SwiftUI

struct TermsnprivacyView: View {
    
    let url: URL
    
    @Binding var isPoped: Bool
    
    var body: some View {
        NavigationView {
            WebView(request: URLRequest(url: url))
                .navigationBarTitleDisplayMode(.inline)
                .navigationBarItems(
                    trailing: Button(action: {
                        isPoped.toggle()
                    }, label: {
                        Text("done", bundle: .module)
                    })
                    .navigationViewStyle(StackNavigationViewStyle())
                    .colorScheme(.dark)
                )
        }
    }
}

struct TermsnprivacyView_Previews: PreviewProvider {
    static var previews: some View {
        TermsnprivacyView(url: URL(string: "https://hoa.wang")!, isPoped: .constant(false))
    }
}

import WebKit

struct WebView : UIViewRepresentable {
    
    let request: URLRequest
    
    func makeUIView(context: Context) -> WKWebView  {
        return WKWebView()
    }
    
    func updateUIView(_ uiView: WKWebView, context: Context) {
        uiView.load(request)
    }
    
}
